using System;
using System.Collections.Generic;
using System.Text;
using WindowsLive.Writer.Api;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace LWCodePastPlugin
{
    [ProgId("Source code Snippet")]
    [WriterPluginAttribute("AA5BA73D-28A8-46c1-A222-4066A65DAEE3", "Source Code", ImagePath = "icon.png", PublisherUrl = "http://sharpsoft.net", Description = "Past formatted source code to Windows Live Writer", Id = "AA5BA73D-28A8-46c1-A222-4066A65DAEE3", HasEditableOptions = true)]
    [InsertableContentSource("Source Code", MenuText = "Source Code Snippet", SidebarText = "Source Code Snippet")]
    public class CodePastPlugin : ContentSource
    {
        public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
        {
            DialogResult res = DialogResult.Cancel;
            using (frmSource frm = new frmSource())
            {
                frm.Owner = dialogOwner as Form;
                res = frm.ShowDialog();
                if (res == DialogResult.OK)
                {
                    content = frm.FormattedOutput;
                }
            }
            return res;
        }

        public override void EditOptions(IWin32Window dialogOwner)
        {
            using (frmAbout a = new frmAbout())
            {
                a.Owner = dialogOwner as Form;
                a.ShowDialog();
            }
        }        
    }
}
